import { Modal } from 'antd'
import { useCallback, useRef } from 'react'
import AdminForm from '../AdminForm'

const AddAdminModle = (props) => {
  const formIns = useRef()
  const { visible, showModel } = props
  // 点击确定 提交增加信息 并 关闭 对话框modal
  const handleOk = useCallback(async () => {
    const verify = await formIns.current.submit()
    if (verify) showModel(false, true)
    // await formIns.current.clear()
  }, [visible])
  // 点击取消 隐藏 我想加一个清除功能却加不了
  const handleCancel = useCallback(async () => {
    await formIns.current.clear()
    showModel()
    console.log(formIns.current)
  }, [visible])
  return (
    <>
      <Modal title="新增管理员" visible={visible} onOk={handleOk} onCancel={handleCancel}>
        <AdminForm ref={formIns} />
      </Modal>
      <span />
    </>
  )
}
export default AddAdminModle
